<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

    <!-- 引入JSON数据展示样式 -->
    <link href="./js_example/script/script/utils/json/search.css" rel="stylesheet">
    <link href="./js_example/script/script/utils/json/prety-json.css" rel="stylesheet">
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>
    <div class="card-panel card-panel-top-right">
        <div class="card-json-info">
            <div class="input-item">
                <div class="input-item-prepend">
                    <span class="input-item-text" style="width:50px;">关键字</span>
                </div>
                <input id='keyWord' type="text" autocomplete="off" style="width: 150px;" value="430224">
                <button onclick="querySearchResult()" class="demo-btn"
                    style="height: 30px;border-bottom-left-radius: 0;border-top-left-radius: 0;">geo查询
                </button>
                <button onclick="querySearchResult1()" class="demo-btn"
                    style="height: 30px;border-bottom-left-radius: 0;border-top-left-radius: 0;">arc查询
                </button>
            </div>
            <div class="info"><span id="result-info"></span></div>
        </div>
    </div>
    <div id="mapui"></div>
    <div id="search_key_tem" style="display:none;width: 220px;height:100px;word-break: normal ">
        <b>行政名称:</b>~[xzmc]<br />
        <b>行政编码:</b>~[xzbm]<br />
    </div>
    <div id="search_key_tem1" style="display:none;width: 220px;height:100px;word-break: normal ">
        <b>行政名称:</b>~[行政区_]<br />
        <b>标识码:</b>~[标识码]<br />
    </div>
    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <script>
        

        var amap = null;
        let geoSearchService = null;
        let arcSearchService = null;

        map.Factory.create('mapui', {
            style: style,
            center: center,
            zoom: 11,
            strategy: ['mapboxgl', 'openlayers', 'leaflet'],
            fullExtent: {
                xmin: 108.23365,
                ymin: 17.95253,
                xmax: 111.78395,
                ymax: 20.13104
            }
        }, (o) => {
            amap = o;


        });

        function querySearchResult() {
            if (geoSearchService) {
                geoSearchService.clear();
            }

            var keyWord = document.getElementById("keyWord").value;

            map.Factory.SimpleSearch('KeySearch', function (keySearch) {
                geoSearchService = keySearch
                keySearch.init('geoserver', {
                    infoTemplateId: "search_key_tem",//弹窗模板ID
                });
                keySearch.search({
                    baseUrl: 'http://129.211.11.95:8066/geoserver/itfeer/wfs',
                    keyWord: keyWord,
                    layerName: 'jtjs_jc_xiang_pt',
                    contains: true,
                    keyField: 'xzbm',
                    // keyWord: 1,
                    // layerName: 'jtjs_jc_xiang_py',
                    // contains: false,
                    // keyField: 'objectid',
                }, (e) => {
                    //对查询的数据定位，并且在地图上展示
                    keySearch.localByBounds();
                    keySearch.showFeatures();
                })
            })

        }

        function querySearchResult1() {
            if (arcSearchService) {
                arcSearchService.clear();
            }

            var keyWord = document.getElementById("keyWord").value;


            map.Factory.SimpleSearch('KeySearch', function (keySearch) {
                arcSearchService = keySearch
                keySearch.init('arcgis', {
                    infoTemplateId: "search_key_tem1",//弹窗模板ID
                });
                keySearch.search({
                    baseUrl: 'http://localhost:6080/arcgis/rest/services/jtjs_jc_cun_py/MapServer',
                    keyWord: '村',
                    layerName: '0',
                    contains: true,
                }, (e) => {
                    //对查询的数据定位，并且在地图上展示
                    keySearch.localByBounds();
                    keySearch.showFeatures();
                })
            })
        }


    </script>
</body>

</html>